<template>
  <div>
    <el-form :inline="true" class="demo-form-inline" :disabled="!!visible">
      <el-form-item label="一级菜单" class="option">
        <el-select
          placeholder="一级菜单"
          :value="cartGory1Id"
          @change="cartGory2"
        >
          <el-option
            :label="c1.name"
            :value="c1.id"
            v-for="c1 in cartGory1List"
            :key="c1.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级菜单" class="option">
        <el-select
          placeholder="二级菜单"
          :value="cartGory2Id"
          @change="cartGory3"
        >
          <el-option
            :label="c2.name"
            :value="c2.id"
            v-for="c2 in cartGory2List"
            :key="c2.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级菜单" class="option">
        <el-select
          placeholder="三级菜单"
          :value="cartGory3Id"
          @change="getList"
        >
          <el-option
            :label="c3.name"
            :value="c3.id"
            v-for="c3 in cartGory3List"
            :key="c3.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapState, mapActions, mapMutations } from "vuex";

export default {
  name: "CartGory",
  data() {
    return {};
  },
  props: ["visible"],
  methods: {
    ...mapActions("cartgory", [
      "cartGory1",
      "cartGory2",
      "cartGory3",
      "set3Id",
      "setAttr",
    ]),
    ...mapMutations("cartgory", ["SET3ID"]),
    getList(e) {
      this.SET3ID(e);
    },
  },
  computed: {
    ...mapState("cartgory", [
      "cartGory1List",
      "cartGory2List",
      "cartGory3List",
      "cartGory1Id",
      "cartGory2Id",
      "cartGory3Id",
    ]),
  },
  mounted() {
    this.cartGory1();
  },
  // watch: {
  //   list1(newValue) {
  //     // console.log(newValue);
  //     this.cartGory2(newValue);
  //   },
  // },
};
</script>

<style scoped>
.option {
  margin: 10px;
}
</style>